package com.itheima.controller;

import com.itheima.entity.Result;
import com.itheima.service.IndexService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @Author: Felix(李鑫)
 * @Date: 2020/9/1 9:52
 * @Description: 首页相关的接口
 */

@RestController
@RequestMapping("/index")
public class IndexController {

    @Autowired
    private IndexService indexService;


    /**
     * 获取一年内的文章贡献数
     * @return
     */
    @GetMapping("/getBlogContributeCount")
    public Result getBlogContributeCount(){

        Map blogContributeCount = indexService.getBlogContributeCount();

        return new Result("success",blogContributeCount);
    }

    /**
     * 获取每个分类下文章数目
     * @return
     */
    @GetMapping("/getBlogCountByBlogSort")
    public Result getBlogCountByBlogSort(){
        Result result = indexService.getBlogCountByBlogSort();
        result.setCode("success");
        return result;
    }

    /**
     * 获取每个标签下文章数目
     * @return
     */
    @GetMapping("/getBlogCountByTag")
    public Result getBlogCountByTag(){

       Result result =  indexService.getBlogCountByTag();

       result.setCode("success");
      return result;
    }

    /**
     * 获取最近一周独立IP数和访问量
     * @return
     */
    @GetMapping("/getVisitByWeek")
    public Result getVisitByWeek(){
        //todo 待完善
        return new Result();
    }

    /**
     * 首页初始化数据
     * @return
     */
    @GetMapping("/init")
    public Result init(){
        //todo: 待完善
        return new Result();
    }


}
